package com.splant.android.smart.SystemDefinedLevel.Utils;

import android.graphics.Point;

/**
 * Created by Administrator on 2016/8/24.
 */
public class System_Math_Util {



    public static double getDistance(Point point1, Point point2) {
        return getDistance(point1.x, point1.y, point2.x, point2.y);
    }

    public static double getDistance(int x1, int y1, int x2, int y2) {
        double xPow = Math.pow(x1 - x2, 2);
        double yPow = Math.pow(y1 - y2, 2);
        return Math.sqrt(xPow + yPow);
    }

    public static double getDistance(float x1, float y1, float x2, float y2) {
        float disX = x2 - x1;
        float disY = y2 - y1;

        double r = Math.sqrt(Math.pow(disX, 2) + Math.pow(disY, 2));

        return r;
    }

    public static double getAngleADegree(int ax, int ay, int bx, int by, int cx, int cy) {
        double a = getDistance(bx, by, cx, cy);
        double b = getDistance(ax, ay, cx, cy);
        double c = getDistance(ax, ay, bx, by);

        double v1 = Math.pow(b, 2) + Math.pow(c, 2) - Math.pow(a, 2);
        double v2 = 2 * b * c;
        return Math.acos(v1 / v2);
    }
    public static double getAngleBDegree(int ax, int ay, int bx, int by, int cx, int cy) {
        double a = getDistance(bx, by, cx, cy);
        double b = getDistance(ax, ay, cx, cy);
        double c = getDistance(ax, ay, bx, by);

        double v1 = Math.pow(c, 2) + Math.pow(a, 2) - Math.pow(b, 2);
        double v2 = 2 * a * c;
        return Math.acos(v1 / v2);
    }

}
